using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UpdateParametersPage : System.Web.UI.Page
{
    GridView gridView;
    SqlDataSource sqlDataSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlDataSource = new SqlDataSource();
        sqlDataSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        ShowData();
        UpdateData("Site");
        ShowData();
    }

    void ShowData()
    {
        sqlDataSource.SelectCommandType =
                SqlDataSourceCommandType.Text;
        sqlDataSource.SelectCommand =
        "select * from tblHitCounter";
        gridView = new GridView();
        this.form1.Controls.Add(gridView);
        gridView.DataSource = sqlDataSource;
        gridView.DataBind();

    }

    void UpdateData(string name)
    {

        sqlDataSource.UpdateCommandType =
        SqlDataSourceCommandType.Text;
        sqlDataSource.UpdateCommand =
        "Update tblHitCounter "+
        " Set HitCounter=HitCounter+1" +
        " where Name=@Name";
        Parameter parameter = new
        Parameter("Name",
        TypeCode.String, name);
        sqlDataSource.UpdateParameters.Add(parameter);
        sqlDataSource.Update();


    }
}
